<template>
    <div class="sharebox">
        <div class="sharebox_con">
            <div class="sharebox_title">
                <div class="shareleft"></div>
                <span class="shareName" v-text="shareName" />
                <div class="shareright"></div>
            </div>

            <div class="sharebox_iconCon">
                <div class="sharebox_iconwefriend" @click="e_goshare(0)"></div>
                <div class="sharebox_iconwepark" @click="e_goshare(1)"></div>
            </div>
        </div>

        <div class="closeshare" @click="e_closeshare"></div>
    </div>
</template>

<script>
export default {
	name: 'sharebox',
	data() {
		return {
			shareName: '立即分享',
		}
	},

	components: {},

	computed: {},

	methods: {
		// 关闭分享
		e_closeshare() {
			this.$store.state.share = false
		},
		// ==============================分享👇====================================//
		e_goshare(type) {
			type == 0 ? this.shareToFriend() : this.shareToPark()
		},
		// 分享到微信好友
		shareToFriend() {
			let _this = this
			Wechat.share(
				{
					message: {
						title: 'Polo商城',
						description: '阅汇诚品，一个会赚钱的APP',
						// thumb: './image/1530326955.png',
						mediaTagName: 'TEST-TAG-001',
						messageExt: '这是第三方带的测试字段',
						messageAction: '',
						media: {
							type: Wechat.Type.IMAGE,
							image: localStorage.getItem('encodePath'),
						},
					},
					scene: Wechat.Scene.SESSION, // share to SESSION
				},
				function() {
					// alert("Success");
					_this.e_closeshare()
				},
				function(reason) {
					// alert("Failed: " + reason);
				},
			)
		},
		// 分享到微信朋友圈
		shareToPark() {
			let _this = this
			Wechat.share(
				{
					message: {
						title: 'Polo商城',
						description: '阅汇诚品，一个会赚钱的APP',
						// thumb: './image/1530326955.png',
						mediaTagName: 'TEST-TAG-001',
						messageExt: '这是第三方带的测试字段',
						messageAction: '',
						media: {
							type: Wechat.Type.IMAGE,
							image: localStorage.getItem('encodePath'),
						},
					},
					scene: Wechat.Scene.Timeline, // share to Timeline
				},
				function() {
					// alert("Success");
					_this.e_closeshare()
				},
				function(reason) {
					// alert("Failed: " + reason);
				},
			)
		},
		// ==============================分享👆====================================//
	},

	mounted() {},
}
</script>
